<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改公告</title>

    <meta name="pragma" content="no-cache">
    <meta name="cache-control" content="no-cache">
    <meta name="content-type" content="text/html;charset=UTF-8">
    <meta name="expires" content="0">
    <div th:replace="~{commons/script::script}"></div>

</head>

<style type="text/css">
    .myselect{
        height:30px;
        width:80%;

    }
</style>

<body style="width:100%;max-width:600px;padding:10px 30px;">
<form id="form" method="post">
    <strong>基本信息</strong>

    <section class="info-section">

        <table id="tb">
            <tr>
                <td class="text-title"> 标题：</td>
                <td>
                    <input type="text" style="width:80%;" name="title" th:value="${announcement.title}"
                           class="easyui-textbox theme-textbox-radius" >
                    <input type="hidden" name="id" th:value="${announcement.id}"/>
                </td>
            </tr>
            <tr>
                <td class="text-title"> 颜色：</td>
                <td>
                    <input type="text" style="width:80%;" name="color" th:value="${announcement.color}"
                           class="easyui-textbox theme-textbox-radius" >

                </td>
            </tr>
            <tr>
                <td class="text-title"> 排序编号：</td>
                <td>
                    <input type="text" style="width:80%;" name="orderId" th:value="${announcement.orderId}"
                           class="easyui-textbox theme-textbox-radius" >
                </td>
            </tr>
            <tr>
                <td class="text-title"> 是否显示：</td>
                <td>
                    <input type="radio" name="isshow" value="1" th:checked="${announcement.isshow==1?true:false}" />是
                    <input type="radio" name="isshow" value="0" th:checked="${announcement.isshow==0?true:false}" />否
                </td>
            </tr>
            <tr>
                <td class="text-title">  是否发布：</td>
                <td>
                    <input type="radio" name="status" value="1" th:checked="${announcement.status==1?true:false}" />是
                    <input type="radio" name="status" value="0" th:checked="${announcement.status==0?true:false}" />否
                </td>
            </tr>
            <tr>
                <td class="text-title">通知部门：</td>
                <td class="text-content">
                    <select  class="myselect" name="department">
                        <option value="-1">请选择部门</option>
                        <option th:each="depart:${departments}" th:selected="${depart.id}==${announcement.getDepartment()}"
                                th:value="${depart.id}" th:text="${depart.name}"></option>
                    </select>
                </td>

            </tr>
            <tr>
                <td class="text-title">内容</td>
                <td class="text-content">
                    <textarea name="content" rows="10" style="width:80%;" th:text="${announcement.content}"></textarea>
                </td>
            </tr>


            <tr>
                <td colspan="2" style="text-align: center;margin-top: 10px;">
                    <a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary">修改</a>
                    <a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-danger">重置</a>
                </td>
            </tr>

        </table>
    </section>
</form>

<script type="text/javascript">
    $(function() {
        //重置按钮
        $("#resetBtn").on("click",function(event){
            $("#form").form("reset");
        });

        //为保存按钮添加事件
        $("#saveBtn").on("click",function(event){
            $("#form").form("submit",{
                url:"/announcement/changes1",
                onSumbit : function(){
                    //调用easyui中form对象的validate方法对表单中数据进行校验，该方法返回boolean值，如果为false会阻止表单提交
                    return $("#form").form("validate");
                },
                success : function(data){
                    var obj = eval("("+data+")");
                    if(obj.success){
                        $.messager.alert("提示",obj.message);
                        parent.closeTopWindow();
                    }else{
                        $.messager.alert("警告",obj.message);
                    }
                }
            });
        });
    });
</script>
</body>
</html>

